<?php
    header("content-type:text/html; charset=utf8");
    $con = mysqli_connect("localhost", "root", "guodong", "study");
    mysqli_set_charset($con, "utf8");
    
    $id = $_GET['id'];

    class Stus
    {
        public $id;
        public $name;
        public $age;
        public $sex;
        public $class;
    }

    if ($con) {
        $sql = "SELECT * FROM stu WHERE id='$id'";
        $select_stu = mysqli_query($con, $sql);
        $this_stu = mysqli_fetch_assoc($select_stu);

        $stus = new Stus();
        $stus -> id = $this_stu['id'];
        $stus -> name = $this_stu['name'];
        $stus -> age = $this_stu['age'];
        $stus -> sex = $this_stu['sex'];
        $stus -> class = $this_stu['class'];
        $data[] = $stus;

        echo json_encode($data);
    } else {
        echo "数据库连接失败！";
    }
